package Shop;

import java.util.Scanner;

import fruit.*;

public class Shop {
    public static void main(String[] args) {
        try {
            // 购买苹果
            System.out.println("请输出要买的苹果重量:");
            Scanner scanner = new Scanner(System.in);
            String appleWeightStr = scanner.next();
            Double appleWeight = Double.valueOf(appleWeightStr);
            Apple apple = new Apple(appleWeight, 1d);
            Double applePrice = apple.getPrice();
            System.out.println("苹果总价:" + applePrice.toString());

            //购买草莓
            System.out.println("请输出要买的草莓重量:");
            String strawWeightStr = scanner.next();
            Double strawWeight = Double.valueOf(strawWeightStr);
            //  修改折扣
            Straw straw = new Straw(strawWeight, 0.8d);
            Double strawPrice = straw.getPrice();
            System.out.println("草莓总价:" + strawPrice.toString());

            //购买芒果
            System.out.println("请输出要买的芒果重量:");
            String mangoWeightStr = scanner.next();
            Double mangoWeight = Double.valueOf(mangoWeightStr);
            Mango mango = new Mango(mangoWeight, 1d);
            Double mangoPrice = mango.getPrice();
            System.out.println("芒果总价:" + mangoPrice.toString());

            // 计算总价
            System.out.println("总价:" + (applePrice + strawPrice + mangoPrice));
        }catch(NumberFormatException ex){
            System.out.println("数量格式不正确");
        }
    }
}

